package com.lcdpg.lcdp.auth.dao;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.lcdpg.lcdp.auth.model.Role;
import com.lcdpg.lcdp.auth.model.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

@Mapper
public interface UserMapper extends BaseMapper<User> {
    // 无需编写方法，继承 BaseMapper 即可获得 CRUD 方法
    @Select("SELECT ur.* FROM users u " +
            "LEFT JOIN user_roles ur ON u.id = ur.user_id " +
            "WHERE u.id = #{userId}")
    Set<Role> findRolesByUserId(Long userId);
}